﻿using System.Web.Mvc;

namespace myMvcBlog.Areas.Admin
{
    public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "admin";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "PostsUnderCategory",
                "Admin/{categoryUrl}/Posts",
                new { controller = "Posts", action = "PostsByCategory" },
                new[] { "myMvcBlog.Areas.Admin.Controllers" }
                );

            context.MapRoute(
                "DeletePost",
                "Admin/Posts/Delete/{postId}",
                new { controller = "Post", action = "Delete" }
                );

            context.MapRoute(
                "DeletePostTag",
                "Admin/Posts/{postId}/DeleteTag/{tagId}",
                new { controller = "Post", action = "DeleteTag" },
                new[] { "myMvcBlog.Areas.Admin.Controllers" }
                );

            context.MapRoute(
               "EditPost",
               "Admin/Post/Edit/{postId}",
               new { controller = "Post", action = "Edit" },
               new[] { "myMvcBlog.Areas.Admin.Controllers" }
               );

            context.MapRoute(
                "AdminDefault",
                "Admin",
                new { controller = "Admin", action = "Index" },
                new[] { "myMvcBlog.Areas.Admin.Controllers" }
                );

            context.MapRoute(
                "admin_default",
                "Admin/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional },
                new[] { "myMvcBlog.Areas.Admin.Controllers" }
            );
        }
    }
}
